package com.codeoss.framework.view.renderer;

import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.chart.GaugeComponent;

@Service("gaugeRenderer")
public class GaugeComponentRenderer extends CommonComponentRenderer {
	protected void startRenderView(YunContext yunContext, Component component, ViewSerializeMap viewSerializeMap) {
		super.startRenderView(yunContext, component, viewSerializeMap);
		GaugeComponent gaugeComponent=(GaugeComponent)component;
		viewSerializeMap.put("title", gaugeComponent.getTitle());
		viewSerializeMap.put("subtitle", gaugeComponent.getSubtitle());
		viewSerializeMap.put("min", gaugeComponent.getMin());
		viewSerializeMap.put("max", gaugeComponent.getMax());
		viewSerializeMap.put("col", gaugeComponent.getCol());
	}
	
	protected PropSerializeMap startRenderProp(YunContext yunContext,
			Component component, ViewPropMap viewPropMap) {
		PropSerializeMap propSerializeMap=super.startRenderProp(yunContext, component, viewPropMap);
		Long value=yunContext.getAttribute(component.getId()+"_chartdata");
		if(value!=null) {
			propSerializeMap.put("value", value);
		}
		return propSerializeMap;
	}
}
